Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

143
Views
Spring HATEOAS resourcesupport -> domain object

While serving objects we use toResource method to transform them into resources and on the way back (posting a resource representation from client to server) how can I transform the representation back to the domain object?

I want to construct Book(@Entity) class from BookResource(extends ResourceSupport) class.

@RequestMapping(path="/", method = RequestMethod.POST, produces="application/vnd.company.app.book-v1+hal+json")
    public ResponseEntity<?> addBook(@RequestBody BookResource bookResource) {
        //What to do here?
    }
about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Your BookResource should extend Resource rather than ResourceSupport.

public class BookResource extends Resource<Book> {

    public BookResource(Book content, Link... links) {
        super(content, links);
    }

}

That way, you get the getContent() method for free, which "Returns the underlying entity."

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!